package vincent.com.layouttest.view;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

import vincent.com.layouttest.R;

/**
 * Created by zvin-chen on 16/12/8.
 */

public class SelectTFCardDialog extends Dialog implements View.OnClickListener{

    OnBtnClickListener mListener;

    private View tf1, tf2;

    public SelectTFCardDialog(Context context, OnBtnClickListener listener) {
        super(context);
        requestWindowFeature(getWindow().FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_select_tfcard);

        this.mListener = listener;
    }

    @Override
    public void onClick(View v) {
        if(R.id.tf_1 == v.getId()){
            if(mListener != null){
                mListener.onClick(1);
            }
        }else if(R.id.tf_2 == v.getId()){
            if(mListener != null){
                mListener.onClick(2);
            }
        }
    }

    public interface OnBtnClickListener{
        void onClick(int index);
    }

    @Override
    public void onContentChanged() {
        super.onContentChanged();
        tf1 = findViewById(R.id.tf_1);
        tf2 = findViewById(R.id.tf_2);

        tf1.setOnClickListener(this);
        tf2.setOnClickListener(this);
    }
}
